
const app = getApp();
var util = require('../../utils/util.js');
var OrderListUrl = "userOrderApi/selectOrderList";

var Orderstatus;
var dataValue = [];
var Ordertime = [];

Page({
  data: {
    OrderList:[],
    Orderstatus: "",
    // isnull: true
  },

  onLoad: function (options) {
    wx.showLoading();
    var that = this;

    wx.request({
      url: app.globalData.requestUrl + OrderListUrl,
      header: {
        'content-type': 'application/json'
      },
      method: 'POST',
      data: {//这里写你要请求的参数
        userID: app.globalData.userId,
      },
      success: function (res) {
        wx.hideLoading();
        //将获取到的json数据，
        console.log(res);//打印日志
        if (res.data.status == 1) {

          var list = res.data.list;
          var waitPayList = [];
          if (list.length > 0) {
            for (var i = 0; i < list.length; i++) {
              var dataValue = list[i];
              if (dataValue.status == "C125005") {
                console.log(dataValue)
                waitPayList.push(dataValue);             
              }
              var waitPaylength = waitPayList.length;
              console.log(waitPaylength)
              that.setData({
                OrderList: waitPayList,
                waitPaylength: waitPaylength
              });
            }
          }
        }
      }
    })

  },
  toOrderdetails: function (e) {
    console.log(e)
    wx.navigateTo({
      url: '/pages/order-details/order-details?id=' + e.currentTarget.dataset.id,
    })
  },
  toPay:function(e) {
    console.log(e)
    wx.navigateTo({
      url: '/pages/confirm-pay/confirm-pay?id=' + e.currentTarget.dataset.id + "&money=" + e.currentTarget.dataset.money,
    })
  },
  toIndex:function(e) {
    console.log(e)
    wx.switchTab({
      url: '/pages/index/index'
    })
  },
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },


})